package com.tdam2014.grupo3.entities;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.tdam2014.grupo3.flickr.util.JSONUtils;

public class People {
	
	private String nsid;
	private String username;
	private String realName;
	private int iconServer;
	private int iconFarm;
	private int countPhotoSets;
	
	private List<PhotoSet> photoSets;
	
	public People() {
	}
	
	public People(JSONObject peopleObject) throws JSONException {
		this.nsid = peopleObject.getString("nsid");
		this.username = JSONUtils.getChildValue(peopleObject, "username");
		this.realName = JSONUtils.getChildValue(peopleObject, "realname");
		this.iconServer = Integer.valueOf(peopleObject.getString("iconserver"));
		this.iconFarm = Integer.valueOf(peopleObject.getString("iconfarm"));
		
		if (this.realName == null || this.realName.isEmpty()) this.realName = this.username;
	}

	public String getNsid() {
		return nsid;
	}

	public void setNsid(String nsid) {
		this.nsid = nsid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username.toLowerCase();
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		if(!realName.isEmpty() && realName != null) this.realName = realName;
		else this.realName = this.username;
	}

	public int getIconServer() {
		return iconServer;
	}

	public void setIconServer(int iconServer) {
		this.iconServer = iconServer;
	}

	public int getIconFarm() {
		return iconFarm;
	}

	public void setIconFarm(int iconFarm) {
		this.iconFarm = iconFarm;
	}

	public int getCountPhotoSets() {
		return countPhotoSets;
	}

	public void setCountPhotoSets(int countPhotoSets) {
		this.countPhotoSets = countPhotoSets;
	}

	public List<PhotoSet> getPhotoSets() {
		return photoSets;
	}

	public void setPhotoSets(List<PhotoSet> photoSets) {
		this.photoSets = photoSets;
	}
}
